#include <cmath>
#include <string>
#include <iostream>

using namespace std;
const int N = 50005;
long long arr[N], brr[N], crr[N];
signed main() {
    int n, q, l, r;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    while (cin >> n) {
        for (int i = 1; i <= n; ++ i) cin >> arr[i], arr[i] += arr[i - 1];
        for (int i = 1; i <= n; ++ i) cin >> brr[i], brr[i] += brr[i - 1];
        for (int i = 1; i <= n; ++ i) cin >> crr[i], crr[i] += crr[i - 1];
        cin >> q;
        while (q --) {
            string s;
            cin >> s >> l >> r;
            l > r ? l ^= r ^= l ^= r : 1;
            if (s == "POJIA") cout << brr[r] - brr[l - 1] << '\n';
            else if (s == "ZHONG") cout << crr[r] - crr[l - 1] << '\n';
            else cout << arr[r] - arr[l - 1] << '\n';
        }
    }cout << endl;
    return 0;
}